package org.zwd.computePrice.service;

import java.util.ArrayList;
import java.util.List;

import org.zwd.computePrice.dao.CrabDao;
import org.zwd.computePrice.dao.CrabPriceDao;
import org.zwd.computePrice.domain.Crab;
import org.zwd.computePrice.domain.CrabPrice;

public class CrabService {
	
	private CrabDao crabDao = new CrabDao();
	private CrabPriceDao crabPriceDao = new CrabPriceDao();
	
	public List<Crab> findAllCrab(int isOrder){
		List<Crab> crabList = new ArrayList<Crab>();
		crabList = crabDao.loadAll();
		for(Crab crab : crabList){
			CrabPrice crabPrice = crabPriceDao.loadPrice(crab.getId(),isOrder);
			crab.setCrabPrice(crabPrice);
		}
		
		return crabList;
	}
	
	public Crab findCrabById(int id){
		return crabDao.findCrabById(id);
	}
	
}
